package com.liyk.shop.controller;

import com.liyk.shop.dto.KillProductDto;
import com.liyk.shop.response.Result;
import com.liyk.shop.service.impl.ProductKillService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @program: springcloud-shop
 * @description:
 * @author: lyk
 * @create: 2019-12-12 10:11
 **/
@RestController
@RequestMapping(value = "killProduct")
public class KillProductController {

    @Autowired
    private ProductKillService productKillService;

    /**
     * 商品详情
     */
    @GetMapping(value = "detail/{killId}")
    public Result getDetail(@PathVariable Integer killId){
        return Result.success(productKillService.getKillDetail(killId));
    }

    /**
     * 执行秒杀
     */
    @PostMapping(value = "execute")
    public Result executeKill(@RequestBody KillProductDto dto){
        productKillService.executeKill(dto);
        return Result.success();
    }


}
